#include <Array.au3>

Dim $path = "D:\Games\wow1\Profiles\Miro\j4f\fishing\"

Local $protectedFilesList="fish.xml|[PB]fish.xml" 

<<<<<<< .mine
Func GetAmountOfFiles($_path, $_protectedFilesList)
	Local $_protectedFiles = StringSplit($protectedFilesList, "|") 
=======
Debug("Starting Fishing-Profile Shuffle")
GetRandomFile ($path, $protectedFilesList)
>>>>>>> .r77

<<<<<<< .mine
	; Shows the filenames of all files in the current directory.
	Local $_search = FileFindFirstFile($_path & "*.*")
=======
>>>>>>> .r77

<<<<<<< .mine
	; Check if the search was successful
	If $_search = -1 Then
	    Exit
	EndIf
=======
Func GetRandomFile($_path, $_protectedFilesList)
	Local $_protectedFiles = StringSplit($protectedFilesList, "|") 
	Local $fileArray[1]
>>>>>>> .r77

<<<<<<< .mine
	$_fileCount = 0
	While 1
		Local $file = FileFindNextFile($_search)
		If @error Then ExitLoop

		Local $iIndex = _ArraySearch($_protectedFiles, $file)
		If @error Then
		    $fileCount += 1
		EndIf		
	WEnd

	; Close the search handle
	FileClose($_search)

	Return $_fileCount
EndFunc=======
	; Shows the filenames of all files in the current directory.
	Local $_search = FileFindFirstFile($_path & "pool*.*")

	; Check if the search was successful
	If $_search = -1 Then
	    Exit
	EndIf

	$_fileCount = 0
	While 1
		Local $file = FileFindNextFile($_search)
		If @error Then ExitLoop

		Local $iIndex = _ArraySearch($_protectedFiles, $file)
		If @error Then
			Debug($file)
		    _ArrayAdd($fileArray, $file)
			_ArrayDisplay($fileArray, "$avArray AFTER _ArrayAdd()")
		 EndIf
	WEnd

	; Close the search handle
	FileClose($_search)
	Debug($_fileCount)
	Return $_fileCount
 EndFunc
 
Func GetAmountOfFiles($_path, $_protectedFilesList)
	Local $_protectedFiles = StringSplit($protectedFilesList, "|") 

	; Shows the filenames of all files in the current directory.
	Local $_search = FileFindFirstFile($_path & "*.*")

	; Check if the search was successful
	If $_search = -1 Then
	    Exit
	EndIf

	$_fileCount = 0
	While 1
		Local $file = FileFindNextFile($_search)
		If @error Then ExitLoop

		Local $iIndex = _ArraySearch($_protectedFiles, $file)
		If @error Then
		    $_fileCount += 1
		EndIf		
	WEnd

	; Close the search handle
	FileClose($_search)
	Debug($_fileCount)
	Return $_fileCount
 EndFunc
 
 Func Debug($text)
   ConsoleWrite("DEBUG: " & $text & @CRLF)
EndFunc

Func _ArrayShuffle(ByRef $aArray)
    $n=UBound($aArray)-1
    while $n > 1
        $k = random(0,$n-1,1)
        $tmp = $aArray[$n];
        $aArray[$n] = $aArray[$k];
        $aArray[$k] = $tmp;
        $n-=1
    WEnd
    Return True
EndFunc
	>>>>>>> .r77
